package com.system.controller;

import com.system.function.object.Warehouse;
import com.system.function.service.WarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/warehouse")
public class WarehouseController {

    @Autowired
    private WarehouseService WarehouseService;


    //查询
    @RequestMapping("/s")
    @ResponseBody
    public Map<String,Object> s(Warehouse Warehouse) {
        List<Warehouse> allWarehouse = WarehouseService.getAllWarehouse(Warehouse);
        Map<String,Object> returnMap  = new HashMap<>();
        returnMap.put("total",WarehouseService.getCountWarehouse(Warehouse));
        returnMap.put("rows",allWarehouse);
        return returnMap;
    }
    //查询
    @RequestMapping("/select")
    @ResponseBody
    public List<Warehouse> select(Warehouse Warehouse) {
        List<Warehouse> allWarehouse = WarehouseService.getAllWarehouse(Warehouse);
        return allWarehouse;
    }

    //添加
    @RequestMapping("/add")
    @ResponseBody
    public String add(Warehouse Warehouse) {
        return WarehouseService.addWarehouse(Warehouse);
    }

    //修改
    @RequestMapping("/up")
    @ResponseBody
    public String up(Warehouse Warehouse) {
        return WarehouseService.updateWarehouse(Warehouse);
    }

    //用户删除
    @RequestMapping("/del")
    @ResponseBody
    public String del(Warehouse Warehouse) {
        return WarehouseService.delWarehouse(Warehouse);
    }


}
